package com.example.movie.controller;

import com.example.movie.domain.Movie;
import com.example.movie.domain.R;
import com.example.movie.service.MovieService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class MovieController {
    @Autowired
    MovieService movieService;

    @GetMapping("/movie/query")
    @CrossOrigin
    public R queryMovie(@RequestParam(value = "movieName",required = false) String movieName,@RequestParam("currentPage")Long currentPage,@RequestParam("pageSize")Long pageSize){
        return R.ok(movieService.getMovie(movieName,currentPage,pageSize));
    }

    @GetMapping("/movie/{mId}")
    public R getMovieDetail(@PathVariable("mId") Long mId){
        Movie movie = movieService.getById(mId);
        return R.ok(movie);
    }

}
